package com.mouse.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mouse.entity.DoubleAlleles;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mouse.entity.Reference;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author godson
 * @since 2022-08-07
 */
public interface DoubleAllelesMapper extends BaseMapper<DoubleAlleles> {

    @Select("Select DISTINCT da.* FROM (SELECT gcom.* FROM gene_category gca LEFT JOIN genecategory_genecomposition gg ON gca.gid=gg.gid LEFT JOIN gene_composition gcom ON gg.gcid=gcom.gcid WHERE gca.gid=#{gid}) gcom_result\n" +
            "LEFT JOIN gene_composition_double_alleles gcomda ON gcom_result.gcid=gcomda.gcid LEFT JOIN double_alleles da on gcomda.did=da.did ")
    List<DoubleAlleles> getDoubleAllelesByGid(@Param("gid") Long gid);

    @Select("SELECT da.* FROM gene_composition gcom LEFT JOIN gene_composition_double_alleles gcda ON gcom.gcid=gcda.gcid LEFT JOIN double_alleles da ON gcda.did=da.did WHERE gcom.gcid=#{gcid}")
    List<DoubleAlleles> getDoubleAllelesByGcid(@Param("gcid") Long gcid);

    /***
     * 3.1
     * @param genePairsName
     * @return
     */
    @Select("SELECT * FROM double_alleles WHERE genepairs_name=#{genePairsName}")
    List<DoubleAlleles> getDoubleAllelesByName(@Param("genePairsName") String genePairsName);

    /***
     * 4.2.1
     * @param aid
     * @return
     */
    @Select("SELECT da.* FROM gene_allele ga LEFT JOIN double_alleles_gene_allele daga ON ga.aid=daga.aid LEFT JOIN double_alleles da ON daga.did= da.did WHERE daga.aid=#{aid}")
    List<DoubleAlleles> getDoubleAllelesByAid(@Param("aid") Long aid);


}
